import { dialog, BrowserWindow, FileFilter, SaveDialogSyncOptions } from 'electron';

/**
 * 选择保存路径
 * @param win
 * @param title
 * @param defaultPath
 * @param filters
 * @returns
 */
export function savePathDialog(win?: BrowserWindow, title?: string, defaultPath?: string, filters?: FileFilter[]) {
	const options: SaveDialogSyncOptions = {
		title,
		defaultPath,
		filters,
	};

	if (win) {
		return dialog.showSaveDialogSync(win, options);
	} else {
		return dialog.showSaveDialogSync(options);
	}
}
